<?php

class WSB_View_Helper_HtmlImage
{

    public function htmlImage($srcPath, $width=null, $height=null, $altTitle=null, $border=0, $class=null, $style=null)
    {

    	// Originalfile vorhanden?
    	// Waere es nicht sinnvoller, die Existenz des Zielfiles zu ueberpruefen?
		if(is_null($width) && is_null($height) && is_readable($srcPath)) {
			$size = getimagesize($srcPath);
			$width = $size[0];
			$height = $size[1];
		}
		$altTitle = is_string($altTitle) ? $altTitle : '';
		return sprintf('<img src="%s" width="%s" height="%s" alt="%s" title="%s" border="%s"%s%s />',
			$srcPath,
			$width,
			$height,
			$altTitle,
			$altTitle,
			$border,
			is_string($class) ? ' class="' . $class . '"' : '',
			is_string($style) ? ' style="' . $style . '"' : ''
		);
    }

}
